<?php

namespace Home\Org\Util;

class OAUSERROLE
{
    static private $_instance = null;

    private $mappingModel = null;
    private $roleModel = null;

    private function __construct()
    {
        $this->mappingModel = M('roleUser');
        $this->roleModel = M('role');
    }

    static public function getInstance()
    {
        if (is_null(self::$_instance)) {
            self::$_instance = new OAUSERROLE();
        }
        return self::$_instance;
    }

    /**
     * @param $user_id
     * @return mixed
     * 获取用户的所有角色，例如：1,2,13
     */
    public function getRoleArray($user_id){
        return $this->mappingModel->field("role_id")->where("user_id = {$user_id}")->select();
    }

}